#include <vector>

using std::vector;

class Solution {
public:
    bool canJump(vector<int>& nums) {
        int n = nums.size();
        int far = 0;
        for (int i = 0; i < n; i++) {
            if (i > far||far>=n-1) {
                break;
            }
            far = std::max(far, i + nums[i]);
        }
        return far >= n - 1;
    }
};